﻿<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<%@ page import="com.led.datatype.ExampleDatas" %>
<%@ page import="com.led.datas.ExampleDatasAccess" %>
<%@ page import="com.led.datas.UserAccess" %>
<%@ page import="com.led.datatype.UserInfo" %>
<html>
<head>
<title>Led8 数据管理</title>
</head>
<body>
<%
	String userName = request.getParameter("userName");
	String password = request.getParameter("password");
	String noNeedSeeOthers = null;
	if(null != userName && null != password){
	    if(null != UserAccess.getUserInfoByNamePassword(userName, password)){
	       session.setAttribute("userName", userName);
	       session.setAttribute("password", password);
	       
	       //登录时，同时要修改其它参数
           noNeedSeeOthers = request.getParameter("noNeedSeeOthers");
           if(null != noNeedSeeOthers){
             session.setAttribute("noNeedSeeOthers", noNeedSeeOthers);
           } else {
             session.removeAttribute("noNeedSeeOthers");
           }
	    } else {
	       userName = null;
	       password = null;
	    }
	} else {
	    userName = (String)session.getAttribute("userName");
	    password = (String)session.getAttribute("password");
	    noNeedSeeOthers = (String)session.getAttribute("noNeedSeeOthers");
	}
%>
<% if(null == userName){%>
请登录!, 可使用public/public作为通用的用户登录处理
<% }else{ %>
  欢迎 <%=session.getAttribute("userName")%>登录! 用其它账号再次登录可切换用户
<%}%>
<form method="POST" action="index.jsp" name="form_getBasicInfo" id="form_getBasicInfo">
	<input type="hidden" name="opType" value="getBasic">
	用户名:<input type="text" name="userName" id="userName" style="height:20px;width:150px;font-size:16px;" value="<%=session.getAttribute("userName")%>"/>
	密码:<input type="password" name="password" id="password" style="height:20px;width:150px;font-size:16px;" value="<%=session.getAttribute("password")%>"/>
	只看自己:<input type="checkbox" name="noNeedSeeOthers" value="1" <%if(null !=noNeedSeeOthers){%>checked="checked" <%}%>/>
    <input type="submit" value="登录/切换用户" />
</form>
<%-- <%=session.getAttribute("userName") %>/<%=session.getAttribute("password") %> --%>
<p>----------------------------------功能分割线-----------------------------------------------------------</p>
<p><br/></p>
客户端获取的数据，直接访问 
<%
  String hrefPath = "DataServlet?userName=" + session.getAttribute("userName") + 
		  "&password=" + session.getAttribute("password") +
		  "&noNeedSeeOthers=" + session.getAttribute("noNeedSeeOthers");
%>
<a href="<%=hrefPath%>" >DataServlet</a>

<p>----------------------------------功能分割线-----------------------------------------------------------</p>
<p><br/></p>
<p><br/></p>
<p>上报数据，有权限限制! <a href="dataExample.jsp" target=”_blank”>数据参考</a></p>
<%
  ExampleDatas exampledatas = ExampleDatasAccess.getAllExampleDatasById(1);
  if(null == exampledatas){
     exampledatas = new ExampleDatas("you datas info", "FF 00 01 02 03");
  }
%>
<form method="POST" action="DataServlet" name="form_Input_Leddatas" id="form_Input_Leddatas">
    <input type="hidden" name="opType" value="insert">
    <input type="hidden" name="userName" id="userName" style="height:20px;width:150px;font-size:16px;" value="<%=session.getAttribute("userName")%>"/>
    <input type="hidden" name="password" id="password" style="height:20px;width:150px;font-size:16px;" value="<%=session.getAttribute("userName")%>"/>
info:<input type="text" name="info"  style="height:20px;width:1000px; font-size:16px;" value="<%=exampledatas.getInfo()%>"/>
<p><textarea rows="10" name="dataReal" cols="219"><%=exampledatas.getDatas()%></textarea></p>
<p><input type="submit" value="提交" />
   <input type="reset" value="重置" name="B2"/></p>
</form>

<p>----------------------------------功能分割线-----------------------------------------------------------</p>
<p><br/></p>
<p><br/></p>

<p><%=session.getAttribute("userName")%>用户可使用数据</p>
<jsp:include page="dbMgr.jsp"/>
</body>

</html>
